Raspberry Pi の初期設定
Raspberry Pi Imager による OS の書き込み直後は、SD カードがアンマウントされているため、ディスクユーティリティを使用したり、SD カードを挿し直す等でマウントします。 Raspberry Pi をインストールした SD カードがマウントされると、 /Volumes/boot が見えるようになっているはずです。 WiFi 接続の設定
起動直後から任意の WiFi アクセスポイントに接続できるようにします。
以下のコマンドでWiFiアクセスポイントのPSKを得ます。PASSWORD と SSID は使用する WiFi の SSID と パスワードに変更してください。
% node -e "console.log(require('crypto').pbkdf2Sync('PASSWORD','SSID',4096,32,'sha1').toString('hex'))"
以下のように、 /Volumes/boot/wpa_supplicant.conf を作成してください。 SSID は使用する WiFi の SSID に、 YOUR_PSK は上記で取得した PSK に変更してください。
code:/Volumes/boot/wpa_supplicant.conf
cat > /Volumes/boot/wpa_supplicant.conf <<EOF
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
psk=YOUR_PSK
}
EOF
次のスクリプトで、 wpa_supplicant.conf ファイルを作成し、 /Volumes/boot/ 直下に配置することもできます。
使い方は、第一引数に SSID を、第二引数にパスワードを入力します。
code:js
const crypto = require('crypto')
const fs = require("fs")
const FILE_NAME = 'wpa_supplicant.conf'
ARGV_LENGTH_BASE = 2
if (process.argv.length < ARGV_LENGTH_BASE + 2) {
console.log("Please input SSID and Password")
process.exit();
}
console.log("ssid", ssid)
console.log("password", password)
const psk = crypto.pbkdf2Sync(password, ssid, 4096, 32, 'sha1').toString('hex')
console.log("psk", psk)
const body = `
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="${ssid}"
psk=${psk}
}
`
fs.writeFileSync(FILE_NAME, body)
SSH 接続の設定
% touch /Volumes/boot/ssh
USB OTGの 設定
USB OTG の設定を行うと、USB 経由で SSH 接続ができるようになります。 /Volumes/boot/cmdline.txt を編集
/Volumes/boot/cmdline.txt の rootwait のあとにスペースを空けて、modules-load=dwc2,g_ether を追加
code:/Volumes/boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=9730496b-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh
/Volumes/boot/config.txt を編集
dtoverlay=dwc2 をファイル末尾に追加
% echo "dtoverlay=dwc2" >> /Volumes/boot/config.txt
code:/Volumes/boot/config.txt
# For more options and information see
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
# uncomment to force a console size. By default it will be display's size minus
# overscan.
# uncomment if hdmi display is not detected and composite is being output
# uncomment to force a specific HDMI mode (this will force VGA)
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
# uncomment for composite PAL
#uncomment to overclock the arm. 700 MHz is the default. # Uncomment some or all of these to enable the optional hardware interfaces
# Uncomment this to enable infrared communication.
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
hideyoshi@macmini-kamakura ~ % echo "dtoverlay=dwc2" >> /Volumes/boot/config.txt
hideyoshi@macmini-kamakura ~ % cat /Volumes/boot/config.txt
# For more options and information see
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
# uncomment to force a console size. By default it will be display's size minus
# overscan.
# uncomment if hdmi display is not detected and composite is being output
# uncomment to force a specific HDMI mode (this will force VGA)
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
# uncomment for composite PAL
#uncomment to overclock the arm. 700 MHz is the default. # Uncomment some or all of these to enable the optional hardware interfaces
# Uncomment this to enable infrared communication.
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
dtoverlay=dwc2